#ifndef _DIODY_H_
#define _DIODY_H_

#define LED_DDR DDRD
#define LED_PORT PORTD

#define LEDNr(i) (4+i)
#define LED0 4
#define LED1 5
#define LED2 6
#define LED3 7

inline void LED_on(unsigned char i)
{
	LED_PORT &= ~(1<<LEDNr(i));
}

inline void LED_off(unsigned char i)
{
	LED_PORT |= (1<<LEDNr(i));
}

inline void LED_toggle(unsigned char i)
{
		LED_PORT ^= (1<<LEDNr(i));
}

void LED_init()
{
	//LEDy jako wyjscia DDR = 1
	LED_DDR |= (1<<LED1) | (1<<LED2) | (1<<LED3) | (1<<LED0);

	LED_on(1);
	LED_on(2);
	LED_on(3);

	_delay_ms(200);	
	LED_off(1);
	_delay_ms(200);
	LED_off(2);
	_delay_ms(200);
	LED_off(3);
	_delay_ms(1000);
}

void LED_showValue(unsigned char value)
{
		if (value > 80)
			LED_on(1); else LED_off(1);
		if (value > 160)
			LED_on(2); else LED_off(2);
		if (value > 240)
			LED_on(3); else LED_off(3);
}

void LED_showBinaryValue(unsigned char value)
{
	if (value & 0x01)
		LED_on(1); else LED_off(1);
	if (value & 0x02)
		LED_on(2); else LED_off(2);
	if (value & 0x04)
		LED_on(3); else LED_off(3);
}

void LED_Alarm()
{
	LED_toggle(1);
	LED_toggle(2);
    LED_toggle(3);
}

#endif
